
var map;

function initialize() {
  var mapOptions = {
    zoom: 6
  };
  map = new google.maps.Map(document.getElementById('map-canvas'),
      mapOptions);

  // Try HTML5 geolocation
  if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      var pos = new google.maps.LatLng(position.coords.latitude,
                                       position.coords.longitude);

      document.getElementById("latitude").innerHTML = position.coords.latitude;
      document.getElementById("longitude").innerHTML = position.coords.longitude;
      var infowindow = new google.maps.InfoWindow({
        map: map,
        position: pos,
        content: 'You are here ;) '
      });

      map.setCenter(pos);
      var element = document.getElementById("load");
      element.parentNode.removeChild(element);
    });
  } else {
    document.getElementById('map-canvas').innerHTML = "Gelocation not available";
  }
}

google.maps.event.addDomListener(window, 'load', initialize);